//
//  WEXUserAccount.m
//  microBlog_oc
//
//  Created by apple on 16/4/21.
//  Copyright © 2016年 Hill. All rights reserved.
//

#import "WEXUserAccount.h"

@implementation WEXUserAccount

- (void)setExpires_in:(NSNumber *)expires_in{
    
    _expires_in = expires_in;
    
    
    self.expiresDate = [NSDate dateWithTimeIntervalSinceNow:expires_in.doubleValue];

}


-(instancetype)initWithDict:(NSDictionary *)dict {
    if (self = [super init] ) {
        
        [self setValuesForKeysWithDictionary:dict];
    }
    
    return  self;
}

+(instancetype)userAccountWithDict:(NSDictionary *)dict {
    
    return [[self alloc]initWithDict:dict];
}

//归档
- (void)encodeWithCoder:(NSCoder *)aCoder{
    
    [aCoder encodeObject:self.uid forKey:@"uid"];
    [aCoder encodeObject:self.expires_in forKey:@"expires_in"];
    [aCoder encodeObject:self.access_token forKey:@"access_token"];
    [aCoder encodeObject:self.remind_in forKey:@"remind_in"];
    [aCoder encodeObject:self.name forKey:@"name"];
    [aCoder encodeObject:self.avatar_large forKey:@"avatar_large"];
    [aCoder encodeObject:self.expiresDate forKey:@"expiresDate"];
    
    
    
}

//解档
- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    
    if (self = [super init]) {
        
        
        
        
        self.uid = [aDecoder decodeObjectForKey:@"uid"];
        self.expires_in = [aDecoder decodeObjectForKey:@"expires_in"];
        self.access_token = [aDecoder decodeObjectForKey:@"access_token"];
        self.remind_in = [aDecoder decodeObjectForKey:@"remind_in"];
        self.name = [aDecoder decodeObjectForKey:@"name"];
        self.avatar_large = [aDecoder decodeObjectForKey:@"avatar_large"];
        self.expiresDate = [aDecoder decodeObjectForKey:@"expiresDate"];
        
        
        
    }
    
    return self;
}

@end
